package com.itboye.mybatis.viewmodel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.itboye.mybatis.model.AuthGroupModel;
import com.itboye.mybatis.model.MemberModel;
import com.itboye.mybatis.model.UcenterMemberModel;

import java.util.ArrayList;
import java.util.List;

/**
 * 帐号信息,由多个基本模型组成
 * Created by hebidu on 16/7/20.
 */

@JsonIgnoreProperties(value = {"status"})
public class AccountViewModel extends UcenterMemberModel {


    /**
     * 设置 UcenterMember
     * @param model
     */
    public void setUcenterMemberModel(UcenterMemberModel model){

        setEmail(model.getEmail());
        setId(model.getId());
        setLastLoginIp(model.getLastLoginIp());
        setLastLoginTime(model.getLastLoginTime());
        setMobile(model.getMobile());
        setPassword(model.getPassword());
        setRegIp(model.getRegIp());
        setRegTime(model.getRegTime());
        setStatus(model.getStatus());
        setUpdateTime(model.getUpdateTime());
        setUsername(model.getUsername());

    }

    @Override
    public String toString() {

        return "AccountViewModel{" +
                "memberModel=" + memberModel +
                ", ucenterMemberModel=" + super.toString() +
                " auth_group_list= "+ getAuthGroupModelList().toString()+
                '}';
    }

    public AccountViewModel() {
        memberModel = new MemberModel();
    }

    public AccountViewModel(MemberModel memberModel) {

        this.memberModel = memberModel;
    }


    //用户所属会员组
    private List<UserAuthGroupAccessViewModel> authGroupModelList;

    private  MemberModel memberModel;

    public List<UserAuthGroupAccessViewModel> getAuthGroupModelList() {

        if(authGroupModelList == null){
            return new ArrayList<UserAuthGroupAccessViewModel>();
        }
        return authGroupModelList;

    }

    public void setAuthGroupModelList(List<UserAuthGroupAccessViewModel> authGroupModelList) {
        this.authGroupModelList = authGroupModelList;
    }

    public MemberModel getMemberModel() {
        return memberModel;
    }

    public void setMemberModel(MemberModel memberModel) {
        this.memberModel = memberModel;
    }

}
